﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Documents;
using System.Collections.ObjectModel;
using System.Windows.Media;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Resources;
using System.Windows.Markup;

namespace SDF
{
    public class PageContent : Fragment
    {
        #region Constructor

        public PageContent()
        {
            this.Padding = new Thickness(double.NaN);
        }

        #endregion

        #region Properties

        public Section Section
        {
            get
            {
                if (this.Blocks.Count > 0)
                {
                    var section = this.Blocks[0] as Section;
                    if (section != null)
                        return section;
                }
                return null;
            }
        }

        #endregion

        #region IsValidParent

        public override bool IsValidParent(DependencyObject parent)
        {
            if (parent is SmartPage)
                return true;

            return false;
        }

        #endregion

        #region IsDirectChild Method

        public static bool IsDirectChild(DependencyObject element)
        {
            if (element == null)
                return false;

            var parent = SmartLogicalTreeHelper.GetParent(element);
            if (parent is PageContent)
                return true;

            if (parent is Section)
                return IsDirectChild(parent);

            return false;
        }

        #endregion

        #region Harvesting

        public override SmartBlock GetEmptyCopy()
        {
            var result = new PageContent();
            CopyProperties(result);
            return result;
        }

        #endregion
    }
}
